Load all required libraries.
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.6 v dplyr 1.0.8
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(broom)
Read in raw data from RDS.
raw_data <- readRDS("./n1_n2_cleaned_cases.rds")
Make a few small modifications to names and data for visualizations.
final_data <- raw_data %>% mutate(log_copy_per_L = log10(mean_copy_num_L)) %>%
rename(Facility = wrf) %>%
mutate(Facility = recode(Facility,
"NO" = "WRF A",
"MI" = "WRF B",
"CC" = "WRF C"))
Seperate the data by gene target to ease layering in the final plot
#make three data layers
only_positives <<- subset(final_data, (!is.na(final_data$Facility)))
only_n1 <- subset(only_positives, target == "N1")
only_n2 <- subset(only_positives, target == "N2")
only_background <<-final_data %>%
select(c(date, cases_cum_clarke, new_cases_clarke, X7_day_ave_clarke)) %>%
group_by(date) %>% summarise_if(is.numeric, mean)
#specify fun colors
background_color <- "#7570B3"
seven_day_ave_color <- "#E6AB02"
marker_colors <- c("N1" = '#1B9E77',"N2" ='#D95F02')
#remove facilty C for now
#only_n1 <- only_n1[!(only_n1$Facility == "WRF C"),]
#only_n2 <- only_n2[!(only_n2$Facility == "WRF C"),]
only_n1 <- only_n1[!(only_n1$Facility == "WRF A" & only_n1$date == "2020-11-02"), ]
only_n2 <- only_n2[!(only_n2$Facility == "WRF A" & only_n2$date == "2020-11-02"), ]
Build the main plot
#first layer is the background epidemic curve
p1 <- only_background %>%
plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~new_cases_clarke,
type = "bar",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Daily Cases: ', new_cases_clarke),
alpha = 0.5,
name = "Daily Reported Cases",
color = background_color,
colors = background_color,
showlegend = FALSE) %>%
layout(yaxis = list(title = "Clarke County Daily Cases", showline=TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#renders the main plot layer two as seven day moving average
p1 <- p1 %>% plotly::add_trace(x = ~date, y = ~X7_day_ave_clarke,
type = "scatter",
mode = "lines",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Seven-Day Moving Average: ', X7_day_ave_clarke),
name = "Seven Day Moving Average Athens",
line = list(color = seven_day_ave_color),
showlegend = FALSE)
#renders the main plot layer three as positive target hits
p2 <- plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n1,
symbol = ~Facility,
marker = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n2,
symbol = ~Facility,
marker = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(yaxis = list(title = "SARS CoV-2 Copies/L",
showline = TRUE,
type = "log",
dtick = 1,
automargin = TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#adds the limit of detection dashed line
p2 <- p2 %>% plotly::add_segments(x = as.Date("2020-03-14"),
xend = ~max(date + 10),
y = 3571.429, yend = 3571.429,
opacity = 0.35,
line = list(color = "black", dash = "dash")) %>%
layout(annotations = list(x = as.Date("2020-03-28"), y = 3.8, xref = "x", yref = "y",
text = "Limit of Detection", showarrow = FALSE))
p1
p2
Combine the two main plot pieces as a subplot
#seperate n1 and n2 frames by site
#n1
wrf_a_only_n1 <- subset(only_n1, Facility == "WRF A")
wrf_b_only_n1 <- subset(only_n1, Facility == "WRF B")
wrf_c_only_n1 <- subset(only_n1, Facility == "WRF C")
#n2
wrf_a_only_n2 <- subset(only_n2, Facility == "WRF A")
wrf_b_only_n2 <- subset(only_n2, Facility == "WRF B")
wrf_c_only_n2 <- subset(only_n2, Facility == "WRF C")
#rejoin the old data frames then seperate in to averages for each plant.
wrfa_both <- full_join(wrf_a_only_n1, wrf_a_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke",
## "X7_day_ave_clarke", "Facility", "collection_num", "target",
## "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "se_L", "mean_total_copies",
## "sd_total_copies", "lo_95", "up_95", "log_copy_per_L")
wrfb_both <- full_join(wrf_b_only_n1, wrf_b_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke",
## "X7_day_ave_clarke", "Facility", "collection_num", "target",
## "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "se_L", "mean_total_copies",
## "sd_total_copies", "lo_95", "up_95", "log_copy_per_L")
wrfc_both <- full_join(wrf_c_only_n1, wrf_c_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke",
## "X7_day_ave_clarke", "Facility", "collection_num", "target",
## "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "se_L", "mean_total_copies",
## "sd_total_copies", "lo_95", "up_95", "log_copy_per_L")
#get max date
maxdate <- max(wrfa_both$date)
mindate <- min(wrfa_both$date)
Build loess smoothing figures figures
This makes the individual plots
#**************************************WRF A PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_botha <- ggplot(wrfa_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_botha<<-..y..), method = "loess", color = '#1B9E77',
span = 0.25, n = 828)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_botha
## `geom_smooth()` using formula 'y ~ x'
fit_botha
## [1] 13.05387 13.04900 13.04418 13.03942 13.03472 13.03007 13.02547 13.02094
## [9] 13.01645 13.01202 13.00763 13.00330 12.99903 12.99480 12.99062 12.98649
## [17] 12.98241 12.97838 12.97439 12.97046 12.96656 12.96272 12.95892 12.95516
## [25] 12.95145 12.94778 12.94415 12.94057 12.93702 12.93352 12.93006 12.92664
## [33] 12.92326 12.91991 12.91660 12.91333 12.91010 12.90691 12.90374 12.90062
## [41] 12.89753 12.89447 12.89144 12.88846 12.88552 12.88264 12.87980 12.87702
## [49] 12.87429 12.87161 12.86898 12.86641 12.86389 12.86143 12.85902 12.85667
## [57] 12.85437 12.85213 12.84994 12.84782 12.84575 12.84375 12.84180 12.83991
## [65] 12.83809 12.83632 12.83462 12.83298 12.83141 12.82989 12.82845 12.82706
## [73] 12.82575 12.82449 12.82331 12.82219 12.82114 12.82016 12.81925 12.81841
## [81] 12.81764 12.81694 12.81631 12.81575 12.81526 12.81485 12.81451 12.81425
## [89] 12.81406 12.81394 12.81391 12.81394 12.81406 12.81426 12.81454 12.81490
## [97] 12.81533 12.81584 12.81643 12.81709 12.81782 12.81862 12.81949 12.82043
## [105] 12.82144 12.82251 12.82364 12.82484 12.82610 12.82742 12.82880 12.83023
## [113] 12.83172 12.83327 12.83487 12.83652 12.83823 12.83998 12.84178 12.84363
## [121] 12.84552 12.84746 12.84944 12.85146 12.85352 12.85562 12.85776 12.85993
## [129] 12.86214 12.86439 12.86666 12.86897 12.87130 12.87367 12.87606 12.87936
## [137] 12.88432 12.89078 12.89858 12.90753 12.91746 12.92821 12.93961 12.95148
## [145] 12.96366 12.97597 12.98825 13.00032 13.01201 13.02315 13.03357 13.04310
## [153] 13.05158 13.05882 13.06466 13.06894 13.07300 13.07826 13.08464 13.09205
## [161] 13.10040 13.10959 13.11954 13.13016 13.14136 13.15304 13.16512 13.17752
## [169] 13.19013 13.20287 13.21565 13.22839 13.24098 13.25335 13.26540 13.27704
## [177] 13.28818 13.29874 13.30862 13.31773 13.32599 13.33330 13.33958 13.34473
## [185] 13.34866 13.35130 13.35254 13.35229 13.35048 13.34748 13.34377 13.33938
## [193] 13.33434 13.32867 13.32242 13.31560 13.30826 13.30041 13.29209 13.28333
## [201] 13.27416 13.26460 13.25470 13.24447 13.23396 13.22318 13.21217 13.20096
## [209] 13.18957 13.17805 13.16642 13.15470 13.14163 13.12604 13.10813 13.08808
## [217] 13.06610 13.04237 13.01709 12.99045 12.96264 12.93386 12.90429 12.87414
## [225] 12.84359 12.81284 12.78208 12.75150 12.72130 12.69167 12.66280 12.63488
## [233] 12.60811 12.58269 12.55879 12.53663 12.51638 12.49824 12.48069 12.46213
## [241] 12.44268 12.42246 12.40159 12.38018 12.35834 12.33621 12.31388 12.29148
## [249] 12.26913 12.24693 12.22502 12.20349 12.18248 12.16209 12.14245 12.12367
## [257] 12.10586 12.08915 12.07364 12.05949 12.04669 12.03513 12.02471 12.01531
## [265] 12.00684 11.99916 11.99220 11.98582 11.97993 11.97441 11.96916 11.96407
## [273] 11.95903 11.95393 11.94867 11.94313 11.93721 11.93080 11.92378 11.91606
## [281] 11.90753 11.89807 11.88859 11.88003 11.87230 11.86530 11.85895 11.85316
## [289] 11.84786 11.84294 11.83832 11.83391 11.82964 11.82540 11.82112 11.81670
## [297] 11.81206 11.80711 11.80177 11.79594 11.78954 11.78248 11.77468 11.76583
## [305] 11.75578 11.74464 11.73253 11.71957 11.70587 11.69156 11.67674 11.66155
## [313] 11.64608 11.63048 11.61484 11.59929 11.58395 11.56893 11.55435 11.54033
## [321] 11.52698 11.51444 11.50280 11.49219 11.48273 11.47454 11.46772 11.46241
## [329] 11.45872 11.45498 11.44961 11.44282 11.43482 11.42585 11.41611 11.40582
## [337] 11.39520 11.38447 11.37384 11.36354 11.35377 11.34476 11.33673 11.32989
## [345] 11.32445 11.32065 11.31869 11.31879 11.32117 11.32605 11.33337 11.34285
## [353] 11.35436 11.36776 11.38292 11.39971 11.41800 11.43766 11.45854 11.48052
## [361] 11.50347 11.52726 11.55175 11.57680 11.60230 11.62810 11.65407 11.68008
## [369] 11.70600 11.73170 11.75704 11.78189 11.80612 11.82959 11.85218 11.87375
## [377] 11.89417 11.91330 11.93376 11.95797 11.98552 12.01600 12.04901 12.08414
## [385] 12.12097 12.15911 12.19815 12.23767 12.27727 12.31654 12.35508 12.39247
## [393] 12.42830 12.46218 12.49369 12.52243 12.54798 12.56994 12.58790 12.60397
## [401] 12.62048 12.63733 12.65445 12.67174 12.68911 12.70649 12.72377 12.74088
## [409] 12.75772 12.77421 12.79026 12.80578 12.82068 12.83489 12.84830 12.86083
## [417] 12.87240 12.88292 12.89229 12.90044 12.90727 12.91269 12.91614 12.91724
## [425] 12.91618 12.91316 12.90839 12.90207 12.89439 12.88556 12.87577 12.86523
## [433] 12.85413 12.84268 12.83108 12.81952 12.80821 12.79734 12.78712 12.77775
## [441] 12.76942 12.76234 12.75671 12.75079 12.74283 12.73298 12.72143 12.70832
## [449] 12.69383 12.67812 12.66135 12.64370 12.62532 12.60638 12.58705 12.56749
## [457] 12.54786 12.52834 12.50908 12.49025 12.47202 12.45455 12.43801 12.42256
## [465] 12.40836 12.39558 12.38439 12.37496 12.36743 12.36030 12.35201 12.34270
## [473] 12.33251 12.32157 12.31002 12.29799 12.28562 12.27305 12.26041 12.24785
## [481] 12.23549 12.22347 12.21193 12.20101 12.19083 12.18155 12.17329 12.16618
## [489] 12.16038 12.15601 12.15320 12.15210 12.15290 12.15561 12.16009 12.16621
## [497] 12.17384 12.18286 12.19311 12.20448 12.21683 12.23002 12.24393 12.25841
## [505] 12.27335 12.28860 12.30403 12.31952 12.33492 12.35010 12.36494 12.37930
## [513] 12.39304 12.40604 12.41815 12.42926 12.43922 12.44790 12.45518 12.46091
## [521] 12.46684 12.47469 12.48428 12.49543 12.50794 12.52164 12.53635 12.55189
## [529] 12.56806 12.58470 12.60161 12.61862 12.63554 12.65218 12.66838 12.68394
## [537] 12.69869 12.71243 12.72499 12.73619 12.74584 12.75376 12.75977 12.76368
## [545] 12.76532 12.76450 12.76177 12.75782 12.75273 12.74657 12.73941 12.73131
## [553] 12.72235 12.71258 12.70210 12.69095 12.67921 12.66695 12.65424 12.64114
## [561] 12.62772 12.61406 12.60023 12.58628 12.57229 12.55833 12.54447 12.53077
## [569] 12.51731 12.50415 12.49136 12.47902 12.46718 12.45592 12.44341 12.42797
## [577] 12.40991 12.38953 12.36714 12.34306 12.31757 12.29099 12.26363 12.23579
## [585] 12.20778 12.17991 12.15247 12.12578 12.10015 12.07587 12.05326 12.03262
## [593] 12.01425 11.99847 11.98559 11.97315 11.95868 11.94238 11.92449 11.90521
## [601] 11.88477 11.86340 11.84130 11.81870 11.79582 11.77288 11.75010 11.72770
## [609] 11.70590 11.68491 11.66497 11.64628 11.62907 11.61356 11.59996 11.58851
## [617] 11.57941 11.57289 11.56853 11.56572 11.56433 11.56428 11.56544 11.56773
## [625] 11.57102 11.57522 11.58022 11.58591 11.59219 11.59895 11.60609 11.61350
## [633] 11.62108 11.62872 11.63632 11.64376 11.65095 11.65778 11.66414 11.67140
## [641] 11.68089 11.69244 11.70589 11.72108 11.73785 11.75602 11.77543 11.79593
## [649] 11.81735 11.83952 11.86229 11.88548 11.90893 11.93248 11.95597 11.97923
## [657] 12.00210 12.02442 12.04602 12.06673 12.08640 12.10486 12.12194 12.13749
## [665] 12.15134 12.16472 12.17893 12.19387 12.20947 12.22562 12.24224 12.25925
## [673] 12.27656 12.29408 12.31171 12.32939 12.34701 12.36449 12.38174 12.39867
## [681] 12.41520 12.43124 12.44669 12.46148 12.47552 12.48871 12.50097 12.51222
## [689] 12.52280 12.53313 12.54323 12.55308 12.56271 12.57211 12.58128 12.59023
## [697] 12.59897 12.60750 12.61582 12.62395 12.63187 12.63961 12.64715 12.65451
## [705] 12.66170 12.66871 12.67555 12.68222 12.68873 12.69509 12.70129 12.70735
## [713] 12.71326 12.71904 12.72445 12.72929 12.73362 12.73748 12.74091 12.74397
## [721] 12.74670 12.74915 12.75136 12.75339 12.75527 12.75706 12.75880 12.76055
## [729] 12.76234 12.76422 12.76624 12.76846 12.77091 12.77364 12.77670 12.77995
## [737] 12.78323 12.78651 12.78979 12.79304 12.79626 12.79942 12.80252 12.80554
## [745] 12.80846 12.81127 12.81396 12.81651 12.81891 12.82114 12.82319 12.82504
## [753] 12.82668 12.82809 12.82926 12.83018 12.83083 12.83119 12.83133 12.83131
## [761] 12.83113 12.83080 12.83032 12.82969 12.82892 12.82800 12.82695 12.82576
## [769] 12.82444 12.82300 12.82142 12.81972 12.81790 12.81597 12.81392 12.81175
## [777] 12.80948 12.80710 12.80463 12.80203 12.79931 12.79645 12.79347 12.79036
## [785] 12.78713 12.78376 12.78027 12.77666 12.77291 12.76904 12.76505 12.76093
## [793] 12.75668 12.75231 12.74782 12.74320 12.73846 12.73360 12.72861 12.72350
## [801] 12.71826 12.71291 12.70743 12.70184 12.69612 12.69028 12.68432 12.67823
## [809] 12.67201 12.66566 12.65917 12.65255 12.64580 12.63892 12.63190 12.62476
## [817] 12.61748 12.61007 12.60253 12.59486 12.58706 12.57912 12.57106 12.56287
## [825] 12.55455 12.54610 12.53752 12.52881
#assign fits to a vector
both_trenda <- fit_botha
#extract y min and max for each
limits_botha <- ggplot_build(extract_botha)$data
## `geom_smooth()` using formula 'y ~ x'
limits_botha <- as.data.frame(limits_botha)
both_ymina <- limits_botha$ymin
both_ymaxa <- limits_botha$ymax
#reassign dataframes (just to be safe)
work_botha <- wrfa_both
#fill in missing dates to smooth fits
work_botha <- work_botha %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_botha <- work_botha$date
#create a new smooth dataframe to layer
smooth_frame_botha <- data.frame(date_vec_botha, both_trenda, both_ymina, both_ymaxa)
#WRF A
#plot smooth frames
p_wrf_a <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_botha, y = ~both_trenda,
data = smooth_frame_botha,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha,
'</br> Median Log Copies: ', round(both_trenda, digits = 2)),
line = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_botha, ymin = ~both_ymina, ymax = ~both_ymaxa,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxa, digits = 2),
'</br> Min Log Copies: ', round(both_ymina, digits = 2)),
name = "",
fillcolor = '#1B9E77',
line = list(color = '#1B9E77')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF A") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfa_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#1B9E77', size = 6, opacity = 0.65))
p_wrf_a
save(p_wrf_a, file = "./plotly_objs/p_wrf_a.rda")
#**************************************WRF B PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothb <- ggplot(wrfb_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothb<<-..y..), method = "loess", color = '#D95F02',
span = 0.25, n = 828)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothb
## `geom_smooth()` using formula 'y ~ x'
fit_bothb
## [1] 12.61045 12.60638 12.60238 12.59847 12.59464 12.59088 12.58720 12.58361
## [9] 12.58009 12.57665 12.57329 12.57000 12.56680 12.56367 12.56063 12.55766
## [17] 12.55477 12.55196 12.54922 12.54657 12.54399 12.54149 12.53907 12.53673
## [25] 12.53446 12.53228 12.53017 12.52813 12.52618 12.52430 12.52250 12.52078
## [33] 12.51914 12.51757 12.51608 12.51467 12.51334 12.51208 12.51090 12.50979
## [41] 12.50877 12.50782 12.50695 12.50616 12.50547 12.50489 12.50440 12.50400
## [49] 12.50370 12.50350 12.50339 12.50338 12.50346 12.50363 12.50390 12.50426
## [57] 12.50470 12.50524 12.50587 12.50659 12.50739 12.50828 12.50926 12.51033
## [65] 12.51148 12.51272 12.51404 12.51544 12.51693 12.51850 12.52016 12.52189
## [73] 12.52371 12.52560 12.52757 12.52963 12.53176 12.53397 12.53625 12.53861
## [81] 12.54105 12.54356 12.54614 12.54880 12.55153 12.55434 12.55721 12.56016
## [89] 12.56317 12.56626 12.56942 12.57264 12.57606 12.57978 12.58380 12.58811
## [97] 12.59268 12.59751 12.60258 12.60788 12.61339 12.61910 12.62500 12.63107
## [105] 12.63730 12.64368 12.65019 12.65682 12.66355 12.67037 12.67727 12.68424
## [113] 12.69126 12.69831 12.70538 12.71247 12.71955 12.72661 12.73365 12.74063
## [121] 12.74756 12.75441 12.76118 12.76785 12.77441 12.78084 12.78712 12.79326
## [129] 12.79922 12.80501 12.81059 12.81597 12.82113 12.82674 12.83342 12.84105
## [137] 12.84952 12.85870 12.86848 12.87875 12.88938 12.90026 12.91128 12.92231
## [145] 12.93325 12.94397 12.95436 12.96429 12.97367 12.98236 12.99025 12.99722
## [153] 13.00317 13.00796 13.01314 13.02020 13.02899 13.03935 13.05113 13.06416
## [161] 13.07830 13.09338 13.10924 13.12574 13.14272 13.16001 13.17746 13.19491
## [169] 13.21221 13.22920 13.24573 13.26163 13.27675 13.29094 13.30403 13.31587
## [177] 13.32630 13.33517 13.34232 13.34760 13.35083 13.35188 13.35109 13.34896
## [185] 13.34557 13.34098 13.33526 13.32849 13.32073 13.31206 13.30254 13.29224
## [193] 13.28123 13.26959 13.25737 13.24466 13.23152 13.21802 13.20424 13.19023
## [201] 13.17607 13.16184 13.14759 13.13341 13.11935 13.10549 13.09190 13.07865
## [209] 13.06581 13.05345 13.03980 13.02322 13.00398 12.98236 12.95861 12.93301
## [217] 12.90583 12.87732 12.84777 12.81743 12.78658 12.75548 12.72440 12.69361
## [225] 12.66337 12.63396 12.60564 12.57868 12.55334 12.52990 12.50863 12.48978
## [233] 12.47363 12.45848 12.44251 12.42583 12.40854 12.39075 12.37254 12.35403
## [241] 12.33532 12.31650 12.29768 12.27896 12.26044 12.24223 12.22442 12.20711
## [249] 12.19042 12.17443 12.15925 12.14499 12.13173 12.11960 12.10891 12.09987
## [257] 12.09234 12.08622 12.08137 12.07767 12.07501 12.07326 12.07231 12.07203
## [265] 12.07229 12.07299 12.07399 12.07518 12.07643 12.07763 12.07865 12.07937
## [273] 12.07968 12.07944 12.07854 12.07686 12.07428 12.07067 12.06591 12.05988
## [281] 12.05375 12.04868 12.04456 12.04131 12.03880 12.03695 12.03565 12.03480
## [289] 12.03429 12.03403 12.03391 12.03383 12.03369 12.03338 12.03281 12.03186
## [297] 12.03045 12.02847 12.02581 12.02237 12.01805 12.01276 12.00638 11.99844
## [305] 11.98865 11.97717 11.96415 11.94977 11.93417 11.91753 11.89999 11.88173
## [313] 11.86290 11.84366 11.82418 11.80461 11.78511 11.76585 11.74698 11.72867
## [321] 11.71108 11.69437 11.67869 11.66422 11.65110 11.63951 11.62959 11.62152
## [329] 11.61545 11.60943 11.60156 11.59207 11.58121 11.56922 11.55633 11.54279
## [337] 11.52884 11.51471 11.50065 11.48690 11.47369 11.46126 11.44987 11.43974
## [345] 11.43111 11.42423 11.41933 11.41666 11.41646 11.41895 11.42396 11.43102
## [353] 11.44003 11.45084 11.46335 11.47742 11.49292 11.50974 11.52775 11.54683
## [361] 11.56684 11.58767 11.60919 11.63128 11.65380 11.67665 11.69968 11.72279
## [369] 11.74583 11.76869 11.79125 11.81338 11.83494 11.85583 11.87591 11.89507
## [377] 11.91316 11.93008 11.94815 11.96954 11.99392 12.02091 12.05018 12.08135
## [385] 12.11410 12.14805 12.18286 12.21817 12.25363 12.28889 12.32359 12.35738
## [393] 12.38991 12.42083 12.44977 12.47639 12.50034 12.52126 12.53879 12.55513
## [401] 12.57259 12.59101 12.61025 12.63016 12.65059 12.67138 12.69239 12.71346
## [409] 12.73445 12.75520 12.77557 12.79539 12.81453 12.83283 12.85014 12.86631
## [417] 12.88119 12.89463 12.90648 12.91658 12.92479 12.93096 12.93517 12.93769
## [425] 12.93865 12.93817 12.93637 12.93338 12.92932 12.92432 12.91850 12.91198
## [433] 12.90489 12.89735 12.88949 12.88143 12.87329 12.86520 12.85729 12.84967
## [441] 12.84247 12.83582 12.82984 12.82276 12.81287 12.80043 12.78564 12.76874
## [449] 12.74997 12.72955 12.70772 12.68469 12.66071 12.63600 12.61080 12.58533
## [457] 12.55982 12.53450 12.50961 12.48537 12.46202 12.43978 12.41889 12.39956
## [465] 12.38205 12.36657 12.35335 12.34263 12.33463 12.32739 12.31891 12.30933
## [473] 12.29880 12.28747 12.27549 12.26301 12.25017 12.23714 12.22405 12.21105
## [481] 12.19830 12.18595 12.17414 12.16303 12.15275 12.14348 12.13534 12.12849
## [489] 12.12309 12.11927 12.11720 12.11701 12.11872 12.12216 12.12722 12.13378
## [497] 12.14173 12.15096 12.16136 12.17281 12.18521 12.19843 12.21237 12.22691
## [505] 12.24194 12.25735 12.27303 12.28885 12.30472 12.32052 12.33613 12.35145
## [513] 12.36635 12.38073 12.39448 12.40748 12.41962 12.43078 12.44086 12.44974
## [521] 12.45969 12.47285 12.48893 12.50766 12.52873 12.55188 12.57680 12.60321
## [529] 12.63082 12.65936 12.68852 12.71802 12.74759 12.77692 12.80573 12.83373
## [537] 12.86065 12.88618 12.91005 12.93197 12.95164 12.96879 12.98312 12.99435
## [545] 13.00219 13.00635 13.00805 13.00868 13.00830 13.00695 13.00467 13.00151
## [553] 12.99750 12.99268 12.98711 12.98081 12.97384 12.96624 12.95804 12.94929
## [561] 12.94003 12.93030 12.92014 12.90961 12.89873 12.88756 12.87612 12.86447
## [569] 12.85265 12.84070 12.82866 12.81657 12.80447 12.79242 12.77837 12.76055
## [577] 12.73932 12.71508 12.68821 12.65908 12.62809 12.59561 12.56202 12.52772
## [585] 12.49308 12.45849 12.42432 12.39097 12.35881 12.32823 12.29960 12.27332
## [593] 12.24976 12.22931 12.21235 12.19575 12.17631 12.15434 12.13012 12.10396
## [601] 12.07615 12.04697 12.01674 11.98573 11.95426 11.92261 11.89107 11.85995
## [609] 11.82953 11.80012 11.77201 11.74548 11.72085 11.69840 11.67842 11.66122
## [617] 11.64709 11.63631 11.62773 11.61995 11.61295 11.60671 11.60122 11.59644
## [625] 11.59236 11.58896 11.58622 11.58412 11.58264 11.58176 11.58145 11.58169
## [633] 11.58248 11.58378 11.58557 11.58784 11.59056 11.59371 11.59728 11.60242
## [641] 11.61018 11.62038 11.63283 11.64736 11.66376 11.68187 11.70150 11.72246
## [649] 11.74457 11.76764 11.79150 11.81595 11.84082 11.86591 11.89105 11.91606
## [657] 11.94074 11.96491 11.98839 12.01100 12.03255 12.05285 12.07173 12.08900
## [665] 12.10447 12.11980 12.13667 12.15494 12.17445 12.19505 12.21661 12.23896
## [673] 12.26197 12.28548 12.30935 12.33342 12.35756 12.38162 12.40543 12.42887
## [681] 12.45177 12.47400 12.49540 12.51583 12.53513 12.55317 12.56978 12.58483
## [689] 12.59895 12.61288 12.62660 12.64013 12.65345 12.66659 12.67952 12.69226
## [697] 12.70481 12.71716 12.72931 12.74127 12.75304 12.76462 12.77600 12.78719
## [705] 12.79819 12.80899 12.81961 12.83003 12.84027 12.85032 12.86017 12.86984
## [713] 12.87932 12.88861 12.89764 12.90633 12.91471 12.92279 12.93058 12.93811
## [721] 12.94538 12.95242 12.95923 12.96584 12.97226 12.97851 12.98460 12.99055
## [729] 12.99638 13.00209 13.00772 13.01326 13.01874 13.02418 13.02959 13.03504
## [737] 13.04059 13.04619 13.05183 13.05747 13.06307 13.06862 13.07407 13.07939
## [745] 13.08455 13.08953 13.09429 13.09880 13.10303 13.10695 13.11052 13.11372
## [753] 13.11652 13.11887 13.12076 13.12215 13.12301 13.12331 13.12322 13.12292
## [761] 13.12241 13.12170 13.12077 13.11962 13.11825 13.11666 13.11485 13.11281
## [769] 13.11053 13.10802 13.10527 13.10229 13.09906 13.09558 13.09185 13.08787
## [777] 13.08364 13.07914 13.07439 13.06940 13.06419 13.05876 13.05312 13.04726
## [785] 13.04117 13.03487 13.02833 13.02157 13.01458 13.00736 12.99990 12.99221
## [793] 12.98429 12.97612 12.96772 12.95907 12.95018 12.94104 12.93166 12.92202
## [801] 12.91214 12.90200 12.89161 12.88096 12.87005 12.85888 12.84745 12.83575
## [809] 12.82377 12.81152 12.79899 12.78620 12.77313 12.75980 12.74621 12.73235
## [817] 12.71824 12.70387 12.68925 12.67437 12.65925 12.64388 12.62826 12.61240
## [825] 12.59631 12.57997 12.56340 12.54660
#assign fits to a vector
both_trendb <- fit_bothb
#extract y min and max for each
limits_bothb <- ggplot_build(extract_bothb)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothb <- as.data.frame(limits_bothb)
both_yminb <- limits_bothb$ymin
both_ymaxb <- limits_bothb$ymax
#reassign dataframes (just to be safe)
work_bothb <- wrfb_both
#fill in missing dates to smooth fits
work_bothb <- work_bothb %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothb <- work_bothb$date
#create a new smooth dataframe to layer
smooth_frame_bothb <- data.frame(date_vec_bothb, both_trendb, both_yminb, both_ymaxb)
#WRF B
#plot smooth frames
p_wrf_b <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothb, y = ~both_trendb,
data = smooth_frame_bothb,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb,
'</br> Median Log Copies: ', round(both_trendb, digits = 2)),
line = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothb, ymin = ~both_yminb, ymax = ~both_ymaxb,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxb, digits = 2),
'</br> Min Log Copies: ', round(both_yminb, digits = 2)),
name = "",
fillcolor = '#D95F02',
line = list(color = '#D95F02')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF B") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfb_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#D95F02', size = 6, opacity = 0.65))
p_wrf_b
save(p_wrf_b, file = "./plotly_objs/p_wrf_b.rda")
#**************************************WRF C PLOT********************************************** #add trendlines #extract data from geom_smooth # *********************************span 0.6*********************************** #*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothc <- ggplot(wrfc_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothc<<-..y..), method = "loess", color = '#E7298A',
span = 0.25, n = 828)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothc
## `geom_smooth()` using formula 'y ~ x'
fit_bothc
## [1] 12.05728 12.05042 12.04367 12.03701 12.03045 12.02399 12.01762 12.01136
## [9] 12.00519 11.99912 11.99314 11.98726 11.98147 11.97578 11.97018 11.96467
## [17] 11.95926 11.95394 11.94870 11.94356 11.93851 11.93355 11.92867 11.92388
## [25] 11.91918 11.91457 11.91004 11.90560 11.90124 11.89697 11.89278 11.88867
## [33] 11.88465 11.88071 11.87684 11.87306 11.86936 11.86574 11.86220 11.85873
## [41] 11.85534 11.85203 11.84880 11.84564 11.84255 11.83954 11.83661 11.83374
## [49] 11.83095 11.82823 11.82560 11.82307 11.82063 11.81830 11.81606 11.81393
## [57] 11.81190 11.80997 11.80814 11.80641 11.80478 11.80326 11.80184 11.80052
## [65] 11.79930 11.79819 11.79718 11.79627 11.79547 11.79478 11.79419 11.79370
## [73] 11.79332 11.79304 11.79287 11.79281 11.79286 11.79301 11.79326 11.79363
## [81] 11.79410 11.79468 11.79537 11.79617 11.79707 11.79809 11.79921 11.80045
## [89] 11.80179 11.80325 11.80481 11.80649 11.80828 11.81017 11.81218 11.81431
## [97] 11.81654 11.81889 11.82135 11.82397 11.82679 11.82981 11.83302 11.83643
## [105] 11.84002 11.84379 11.84775 11.85188 11.85617 11.86064 11.86527 11.87006
## [113] 11.87501 11.88010 11.88535 11.89073 11.89626 11.90192 11.90772 11.91364
## [121] 11.91969 11.92586 11.93214 11.93854 11.94504 11.95165 11.95836 11.96517
## [129] 11.97207 11.97906 11.98613 11.99329 12.00052 12.00783 12.01520 12.02398
## [137] 12.03534 12.04902 12.06476 12.08231 12.10141 12.12180 12.14324 12.16546
## [145] 12.18822 12.21124 12.23428 12.25709 12.27940 12.30096 12.32151 12.34081
## [153] 12.35859 12.37459 12.38856 12.40025 12.41164 12.42478 12.43955 12.45580
## [161] 12.47341 12.49225 12.51218 12.53307 12.55478 12.57718 12.60014 12.62353
## [169] 12.64722 12.67106 12.69493 12.71870 12.74222 12.76538 12.78803 12.81004
## [177] 12.83129 12.85163 12.87093 12.88906 12.90589 12.92129 12.93511 12.94724
## [185] 12.95753 12.96586 12.97208 12.97607 12.97769 12.97683 12.97357 12.96808
## [193] 12.96056 12.95117 12.94009 12.92751 12.91360 12.89855 12.88251 12.86569
## [201] 12.84826 12.83038 12.81225 12.79404 12.77594 12.75811 12.74073 12.72400
## [209] 12.70807 12.69314 12.67938 12.66697 12.65390 12.63818 12.62001 12.59961
## [217] 12.57717 12.55292 12.52705 12.49977 12.47128 12.44181 12.41154 12.38070
## [225] 12.34949 12.31811 12.28677 12.25568 12.22505 12.19508 12.16598 12.13796
## [233] 12.11123 12.08599 12.06245 12.04081 12.02129 12.00409 11.98798 11.97162
## [241] 11.95505 11.93830 11.92140 11.90441 11.88734 11.87024 11.85315 11.83611
## [249] 11.81914 11.80229 11.78559 11.76908 11.75280 11.73678 11.72107 11.70568
## [257] 11.69068 11.67608 11.66194 11.64845 11.63578 11.62387 11.61265 11.60207
## [265] 11.59206 11.58257 11.57354 11.56489 11.55658 11.54855 11.54073 11.53306
## [273] 11.52549 11.51795 11.51038 11.50273 11.49493 11.48692 11.47864 11.47004
## [281] 11.46105 11.45161 11.44247 11.43439 11.42725 11.42098 11.41548 11.41066
## [289] 11.40642 11.40268 11.39934 11.39631 11.39350 11.39081 11.38816 11.38546
## [297] 11.38260 11.37950 11.37608 11.37222 11.36785 11.36288 11.35720 11.35040
## [305] 11.34222 11.33278 11.32221 11.31064 11.29820 11.28502 11.27124 11.25697
## [313] 11.24235 11.22751 11.21259 11.19770 11.18298 11.16856 11.15456 11.14113
## [321] 11.12838 11.11645 11.10547 11.09557 11.08687 11.07951 11.07361 11.06931
## [329] 11.06674 11.06454 11.06136 11.05735 11.05267 11.04746 11.04186 11.03604
## [337] 11.03013 11.02429 11.01866 11.01339 11.00864 11.00454 11.00126 10.99893
## [345] 10.99771 10.99774 10.99918 11.00217 11.00686 11.01340 11.02216 11.03330
## [353] 11.04666 11.06211 11.07947 11.09859 11.11932 11.14150 11.16498 11.18961
## [361] 11.21522 11.24166 11.26877 11.29641 11.32442 11.35264 11.38091 11.40908
## [369] 11.43700 11.46451 11.49146 11.51769 11.54304 11.56736 11.59049 11.61229
## [377] 11.63259 11.65124 11.67036 11.69201 11.71588 11.74172 11.76923 11.79813
## [385] 11.82815 11.85901 11.89042 11.92210 11.95377 11.98516 12.01598 12.04595
## [393] 12.07480 12.10223 12.12798 12.15175 12.17328 12.19227 12.20845 12.22323
## [401] 12.23817 12.25320 12.26828 12.28336 12.29838 12.31328 12.32801 12.34253
## [409] 12.35677 12.37069 12.38422 12.39733 12.40994 12.42201 12.43349 12.44432
## [417] 12.45445 12.46382 12.47239 12.48009 12.48688 12.49270 12.49739 12.50087
## [425] 12.50325 12.50460 12.50500 12.50454 12.50332 12.50141 12.49889 12.49586
## [433] 12.49241 12.48860 12.48454 12.48031 12.47599 12.47167 12.46743 12.46336
## [441] 12.45955 12.45607 12.45303 12.44929 12.44379 12.43665 12.42802 12.41802
## [449] 12.40680 12.39449 12.38123 12.36715 12.35239 12.33708 12.32136 12.30537
## [457] 12.28925 12.27312 12.25713 12.24140 12.22609 12.21131 12.19722 12.18393
## [465] 12.17160 12.16036 12.15034 12.14167 12.13450 12.12723 12.11829 12.10786
## [473] 12.09613 12.08327 12.06947 12.05489 12.03974 12.02418 12.00839 11.99257
## [481] 11.97688 11.96150 11.94663 11.93243 11.91909 11.90679 11.89571 11.88603
## [489] 11.87793 11.87159 11.86719 11.86491 11.86436 11.86495 11.86662 11.86931
## [497] 11.87295 11.87746 11.88278 11.88885 11.89559 11.90294 11.91082 11.91918
## [505] 11.92794 11.93703 11.94640 11.95596 11.96565 11.97541 11.98516 11.99484
## [513] 12.00438 12.01371 12.02276 12.03147 12.03977 12.04759 12.05486 12.06152
## [521] 12.06906 12.07888 12.09078 12.10457 12.12004 12.13700 12.15523 12.17454
## [529] 12.19474 12.21561 12.23696 12.25859 12.28029 12.30187 12.32312 12.34384
## [537] 12.36384 12.38291 12.40085 12.41746 12.43254 12.44589 12.45730 12.46658
## [545] 12.47353 12.47794 12.48096 12.48385 12.48660 12.48920 12.49163 12.49389
## [553] 12.49596 12.49782 12.49948 12.50090 12.50209 12.50304 12.50371 12.50412
## [561] 12.50424 12.50405 12.50356 12.50275 12.50160 12.50010 12.49824 12.49601
## [569] 12.49340 12.49039 12.48697 12.48313 12.47886 12.47414 12.46787 12.45910
## [577] 12.44808 12.43505 12.42025 12.40393 12.38634 12.36772 12.34831 12.32836
## [585] 12.30811 12.28780 12.26768 12.24800 12.22900 12.21091 12.19400 12.17850
## [593] 12.16465 12.15270 12.14289 12.13289 12.12037 12.10557 12.08874 12.07014
## [601] 12.05001 12.02860 12.00617 11.98297 11.95924 11.93523 11.91120 11.88740
## [609] 11.86407 11.84146 11.81984 11.79943 11.78051 11.76331 11.74808 11.73509
## [617] 11.72457 11.71677 11.71082 11.70564 11.70118 11.69742 11.69432 11.69184
## [625] 11.68994 11.68858 11.68774 11.68737 11.68744 11.68791 11.68875 11.68991
## [633] 11.69136 11.69306 11.69499 11.69709 11.69934 11.70169 11.70412 11.70756
## [641] 11.71289 11.71998 11.72869 11.73888 11.75040 11.76313 11.77691 11.79162
## [649] 11.80711 11.82324 11.83988 11.85689 11.87413 11.89145 11.90872 11.92581
## [657] 11.94256 11.95885 11.97454 11.98948 12.00353 12.01657 12.02844 12.03901
## [665] 12.04814 12.05693 12.06648 12.07674 12.08761 12.09901 12.11087 12.12310
## [673] 12.13563 12.14838 12.16126 12.17420 12.18711 12.19991 12.21253 12.22489
## [681] 12.23690 12.24849 12.25957 12.27006 12.27989 12.28898 12.29724 12.30459
## [689] 12.31129 12.31765 12.32368 12.32941 12.33486 12.34005 12.34499 12.34970
## [697] 12.35421 12.35853 12.36268 12.36668 12.37056 12.37432 12.37800 12.38160
## [705] 12.38515 12.38867 12.39218 12.39569 12.39923 12.40281 12.40646 12.41019
## [713] 12.41402 12.41798 12.42170 12.42483 12.42744 12.42957 12.43129 12.43263
## [721] 12.43366 12.43443 12.43498 12.43539 12.43569 12.43593 12.43619 12.43649
## [729] 12.43691 12.43749 12.43828 12.43934 12.44073 12.44248 12.44467 12.44723
## [737] 12.45007 12.45315 12.45643 12.45989 12.46347 12.46716 12.47092 12.47471
## [745] 12.47849 12.48223 12.48590 12.48947 12.49289 12.49613 12.49916 12.50194
## [753] 12.50444 12.50662 12.50845 12.50990 12.51092 12.51149 12.51180 12.51208
## [761] 12.51231 12.51249 12.51262 12.51268 12.51267 12.51259 12.51243 12.51218
## [769] 12.51183 12.51138 12.51083 12.51016 12.50937 12.50846 12.50741 12.50622
## [777] 12.50488 12.50339 12.50175 12.49998 12.49814 12.49621 12.49421 12.49212
## [785] 12.48994 12.48768 12.48532 12.48288 12.48033 12.47769 12.47495 12.47211
## [793] 12.46916 12.46610 12.46294 12.45966 12.45627 12.45277 12.44915 12.44540
## [801] 12.44154 12.43755 12.43343 12.42918 12.42480 12.42029 12.41564 12.41084
## [809] 12.40588 12.40076 12.39549 12.39007 12.38449 12.37878 12.37292 12.36692
## [817] 12.36079 12.35453 12.34814 12.34163 12.33499 12.32824 12.32137 12.31439
## [825] 12.30731 12.30012 12.29283 12.28544
#assign fits to a vector
both_trendc <- fit_bothc
#extract y min and max for each
limits_bothc <- ggplot_build(extract_bothc)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothc <- as.data.frame(limits_bothc)
both_yminc <- limits_bothc$ymin
both_ymaxc <- limits_bothc$ymax
#reassign dataframes (just to be safe)
work_bothc <- wrfc_both
#fill in missing dates to smooth fits
work_bothc <- work_bothc %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothc <- work_bothc$date
#create a new smooth dataframe to layer
smooth_frame_bothc <- data.frame(date_vec_bothc, both_trendc, both_yminc, both_ymaxc)
#WRF C
#plot smooth frames
p_wrf_c <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothc, y = ~both_trendc,
data = smooth_frame_bothc,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc,
'</br> Median Log Copies: ', round(both_trendc, digits = 2)),
line = list(color = '#E7298A', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothc, ymin = ~both_yminc, ymax = ~both_ymaxc,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxc, digits = 2),
'</br> Min Log Copies: ', round(both_yminc, digits = 2)),
name = "",
fillcolor = '#E7298A',
line = list(color = '#E7298A')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF C") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfc_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#E7298A', size = 6, opacity = 0.65))
p_wrf_c
save(p_wrf_c, file = "./plotly_objs/p_wrf_c.rda")
save(wrfa_both, file = "./plotly_objs/wrfa_both.rda")
save(wrfb_both, file = "./plotly_objs/wrfb_both.rda")
save(wrfc_both, file = "./plotly_objs/wrfc_both.rda")
save(date_vec_botha, file = "./plotly_objs/date_vec_botha.rda")
save(date_vec_bothb, file = "./plotly_objs/date_vec_bothb.rda")
save(date_vec_bothc, file = "./plotly_objs/date_vec_bothc.rda")
save(both_ymina, file = "./plotly_objs/both_ymina.rda")
save(both_ymaxa, file = "./plotly_objs/both_ymaxa.rda")
save(both_yminb, file = "./plotly_objs/both_yminb.rda")
save(both_ymaxb, file = "./plotly_objs/both_ymaxb.rda")
save(both_yminc, file = "./plotly_objs/both_yminc.rda")
save(both_ymaxc, file = "./plotly_objs/both_ymaxc.rda")